<%--
  Created by IntelliJ IDEA.
  User: Rui
  Date: 2018/9/8
  Time: 9:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html style="background-color: #fff;">
<head>
    <%@include file="../../../../resources/inc/head.jsp" %>
</head>
<body>
<expect-x:tip tipMessage="标识“*”的选项为必填项，其余为选填项。;请按提示信息填写每一个字段" widthClass="full-width-85"/>
<c:set var="id"  value="${paymentChannel.id}"/>
<div class="layui-form common-form" lay-filter="layuiadmin-form-merchantApplication" id="layuiadmin-form-merchantApplication" style="padding: 20px;">
    <div class="layui-form-item">
        <input type="hidden" value="${merchantApplication.id}" name="id">
        <label class="layui-form-label"><span class="require-field">*</span>渠道费率 </label>
        <div class="layui-input-inline"style="width: 200px">
            <input type="text" ${id==6?'disabled':''} value="${id==6?'0.5':''}"maxlength="45" name="typeCode" lay-verify="required" placeholder="请输入渠道费率" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">%</div>
    </div>
    <c:if test="${id ==1||id ==2||id ==3||id ==6}">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>支付宝版本</label>
        <div class="layui-input-inline">
        <select name="" lay-filter="aihao">
            <option value="">请选择</option>
            <option value="0">mapi</option>
            <option value="1" selected="">openapi</option>
        </select>
        </div>
    </div>
    </c:if>
<c:if test="${id ==2}">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>支付宝商户App ID </label>
        <div class="layui-input-inline">
            <input type="text" value="${merchantApplication.typeCode}"maxlength="45" name="typeCode" lay-verify="required" placeholder="请输入支付宝商户App ID" autocomplete="off" class="layui-input">
        </div>
    </div>
</c:if>
<c:if test="${id ==1||id ==2||id ==3||id ==4||id==5||id==6}">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>合作伙伴身份(PID) </label>
        <div class="layui-input-inline">
            <input type="text" value="${merchantApplication.typeCode}"maxlength="45" name="typeCode" lay-verify="required" placeholder="请输入合作伙伴身份(PID)" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>支付宝公匙</label>
        <div class="layui-input-inline">
            <textarea name="typeName" id="" lay-verify="required"maxlength="3000" placeholder="请输入支付宝公匙" autocomplete="off" class="layui-textarea"></textarea>
        </div>
    </div>
</c:if>
<c:if test="${id ==2||id ==4||id==5}">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>密匙类型</label>
        <div class="layui-input-inline">
        <select name="" lay-filter="aihao">
            <option value="RSA(SHA1)">RSA(SHA1)</option>
            <option value="RSA(SHA256)">RSA(SHA256) (推荐)</option>
        </select>
        </div>
    </div>
</c:if>
<c:if test="${id ==1||id ==2||id ==3||id ==4||id==5||id==6}">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>应用私匙</label>
        <div class="layui-input-inline">
            <textarea name="typeName"  lay-verify="required"maxlength="3000" placeholder="请输入应用私匙" autocomplete="off" class="layui-textarea">${merchantApplication.typeName}</textarea>
        </div>
    </div>
</c:if>
<c:if test="${id ==1||id ==2||id ==3||id ==4||id==5}">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>退款时是否退还手续费</label>
        <div class="layui-input-inline">
            <select name="" >
                <option value="0">是</option>
                <option value="1">否</option>
            </select>
        </div>
    </div>
</c:if>
    <c:if test="${id==7||id==10}">




    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>应用AppID </label>
        <div class="layui-input-inline">
            <input type="text" value="${merchantApplication.typeCode}"maxlength="45" name="typeCode" lay-verify="required" placeholder="请输入应用AppID" autocomplete="off" class="layui-input">
        </div>
    </div>
    </c:if>
    <c:if test="${id==8}">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>小程序AppID </label>
        <div class="layui-input-inline">
            <input type="text" value="${merchantApplication.typeCode}"maxlength="45" name="typeCode" lay-verify="required" placeholder="请输入应用AppID" autocomplete="off" class="layui-input">
        </div>
    </div>
    </c:if>
    <c:if test="${id==9||id==11||id==12}">
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="require-field">*</span>公众号AppID </label>
            <div class="layui-input-inline">
                <input type="text" value=""maxlength="45" name="typeCode" lay-verify="required" placeholder="请输入公众号AppID" autocomplete="off" class="layui-input">
            </div>
        </div>
    </c:if>
    <c:if test="${id==7||id==10||id==8||id==9||id==11||id==12}">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>微信支付商户号 </label>
        <div class="layui-input-inline">
            <input type="text" value="${merchantApplication.typeCode}"maxlength="45" name="typeCode" lay-verify="required" placeholder="请输入微信支付商户号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>Api密钥 </label>
        <div class="layui-input-inline">
            <input type="text" value="${merchantApplication.typeCode}"maxlength="45" name="typeCode" lay-verify="required" placeholder="请输入Api密钥" autocomplete="off" class="layui-input">
        </div>
    </div>
    </c:if>
    <%--<c:if test="${id==7||id==8}">--%>
    <%--<div class="layui-form-item">--%>
        <%--<label class="layui-form-label"><span class="require-field">*</span>开启企业付款到银行卡</label>--%>
        <%--<div class="layui-input-inline">--%>
            <%--<select name="" >--%>
                <%--<option value="0">是</option>--%>
                <%--<option value="1">否</option>--%>
            <%--</select>--%>
        <%--</div>--%>
    <%--</div>--%>
    <%--</c:if>--%>
    <c:if test="${id==7||id==10||id==8||id==9||id==11||id==12}">

    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>Api证书</label>
        <div class="layui-input-inline">
            <textarea name="typeName"  lay-verify="required"maxlength="3000" placeholder="请输入Api证书" autocomplete="off" class="layui-textarea">${merchantApplication.typeName}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="require-field">*</span>Api证书密钥</label>
        <div class="layui-input-inline">
            <textarea name="typeName"  lay-verify="required"maxlength="3000" placeholder="请输入Api证书" autocomplete="off" class="layui-textarea">${merchantApplication.typeName}</textarea>
        </div>
    </div>
    <%--<div class="layui-form-item">--%>
        <%--<label class="layui-form-label"><span class="require-field">*</span>是否退还支付手续费</label>--%>
        <%--<div class="layui-input-inline">--%>
            <%--<select name="" >--%>
                <%--<option value="0">是</option>--%>
                <%--<option value="1">否</option>--%>
            <%--</select>--%>
        <%--</div>--%>
    <%--</div>--%>
    <%--<div class="layui-form-item">--%>
        <%--<label class="layui-form-label"><span class="require-field">*</span>微信新资金流</label>--%>
        <%--<div class="layui-input-inline">--%>
            <%--<select name="" >--%>
                <%--<option value="0">是</option>--%>
                <%--<option value="1">否</option>--%>
            <%--</select>--%>
        <%--</div>--%>
    <%--</div>--%>
    </c:if>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-submit" id="LAY-submit" value="确认">
    </div>
</div>

<%@include file="../../../../resources/inc/footer.jsp" %>
<script>
    layui.config({
        base: '<%=basePath%>resources/lib/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'upload'], function(){
        var $ = layui.$
            ,form = layui.form
            ,upload = layui.upload ;


    })
    var id =${id}
    function createSubmit() {
        var layer=layui.layer;
        var submitID = 'LAY-submit';
        layui.form.on('submit('+ submitID +')', function(data){

            var formData = data.field;
            if(!/[0-9_a-zA-z]/.test(formData.typeCode)){
                layer.msg('编号只能是数字,字母和下划线');
                return;
            }
            layer.load(2);
            if(formData.id==""||formData.id==null){
                $.ajax({
                    url:"<%=basePath%>/manager/merchant/create.html",
                    type:"POST",
                    data:formData,
                    dataType:"JSON",
                    success:function (data) {
                        layer.closeAll('loading');
                        if(data.success){
                            layer.msg("创建成功,1秒后跳转")
                        }else{
                            layer.msg(data.message, {icon: 5});
                        }
                    }
                });
            }else{
                $.ajax({
                    url:"<%=basePath%>manager/system/merchantApplication/update/"+formData.id+".html",
                    type:"POST",
                    data:formData,
                    dataType:"JSON",
                    success:function (data) {
                        layer.closeAll('loading');
                        if(data.success){
                            layer.msg("修改成功,1秒后跳转")
                            setTimeout(function () {
                                window.parent.location.reload(); //刷新父页面
                                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(index);
                            },1000);
                        }else{
                            layer.msg(data.message, {icon: 5});
                        }
                    }
                });
            }
        })
        $("#"+submitID).trigger('click');
    }
</script>
</body>
</html>
